$(function() {
	var title=$("#videoTitle").val();
	var videoUri=$("#videoUri").val();
	var imgUri=$("#imgUri").val();
	setTimeout(function(){
		playVideo(title,videoUri,imgUri);
	},400);
	loadCommit($("#loadCommitId").val());
})


/**
 * 加载评论组件
 * @param id
 * @returns
 */
function loadCommit(id){
	try{
		$("#loadCommit").load(V_PATH+"/commitvidoe.action?videoid="+id);
	}catch(err){
		
	}
}

/**
 * 提交评论
 * @returns
 */
function submitCommit(){
	var text=$("#commitText").val();
	var videoid=$("#commitVideoID").val();
	$.ajax({
        url:V_PATH+'/submitCommitVideo.action',
        type:'post',
        data:{"videoid":videoid,"text":text},
        dataType:"json",
        success:function(data){
        	if(data.result=="T"){
        		/**
        		 * 加载评论
        		 */
        		$("#loadCommit").load(V_PATH+"/commitvidoe.action?videoid="+videoid);
        	}else{
        		alert("评论失败,请重试");
        	}
        }
    });
}



/**
 * 播放视频
 * @param title
 * @param videoUri
 * @param imgUri
 * @returns
 */
function playVideo(title,videoUri,imgUri){
	$("#jplayer_1")
	.jPlayer("clearMedia")
	.jPlayer("setMedia"
			, { title: title,m4v:videoUri,
        poster:imgUri})
			.jPlayer("play");
}